home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / TDECSHOW < prev    next >
Encoding:
Text File  |  1985-12-27  |  2.6 KB  |  90 lines

  1. ;-------------------------tdecshow routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 95
  4. ;
  5. ; NAME TDECSHOW
  6. ;
  7. ; ROUTINE FOR DISPLAY OF FLOATING POINT
  8. ;
  9. ; FUNCTION: This routine displays a floating point number on the std
  10. ; output device.
  11. ;
  12. ; INPUT: Upon input a number is stored in temporary decimal floating point
  13. ; form.  The temporary format has a string of 25 decimal digits, a sign
  14. ; byte, and a base ten exponent which is stored in two's complement 16-bit
  15. ; binary format (Fig 5-5).
  16. ;
  17. ; OUTPUT: The individual characters of a floating point number are sent
  18. ; out the standard output device.  The form of the output is: a sign char-
  19. ; acter which is blank or minus, followed by decimal digits of the mantissa
  20. ; with one imbedded decimal point to the right of the first significant
  21. ; digit.  Following the mantissa is an exponent which starts with the letter
  22. ; 'E', then a sign, then a d8cimal number (Fig 5-4).
  23. ;
  24. ; REGISTERS USED:  AL, CX, DX and SI are modified.
  25. ;
  26. ; SEGMENTS REFERENCED:  The data segment contains the variables DECBUFF
  27. ; (25 BYTES), DECSIGN (1 byte), and DECEXP (2 bytes).
  28. ;
  29. ; ROUTINES CALLED:  STDOUT, DEC16OUT
  30. ;
  31. ; SPECIAL NOTES: This is a near procedure needed by FPOUT.
  32. ;
  33. ; ROUTINE TO DISPLAY TEMPORARY DECIMAL FLOATING POINT NUMBERS
  34. ;
  35. tdecshow    proc    near
  36. ;
  37. ; output the sign
  38.     cmp    decsign,0    ; is the sign there ?
  39.     mov    al,' '        ; space if not
  40.     je    decshow1
  41. ;
  42. ; output a minus sign
  43.     mov    al,'-'        ; minus sign
  44. ;
  45. tdecshow1:
  46.     call    stdout        ; send it out
  47. ;
  48. tdecshow2:
  49. ; output the first digit and a decimal point
  50.     lea    si,decbuff+21    ; point to the first digit
  51.     mov    al,[si]        ; get it
  52.     dec    si        ; point to next digit
  53.     add    al,30h        ; convert to ASCII
  54.     call    stdout        ; send it out
  55. ;
  56.     mov    al,'.'        ; ASCII decimal point
  57.     call    stdout        ; send it out
  58. ;
  59. ; output the rest of the decimal string
  60.     mov    cx,7        ; only seven more digits
  61. ;
  62. tdecshow3:
  63.     mov    al,[si]        ; get digit
  64.     dec    si        ; point to next digit
  65.     add    al,30h        ; convert to ASCII
  66.     call    stdout        ; send it out
  67.     loop    tdecshow3    ; until all digits sent
  68. ;
  69.     mov    al,'E'        ; E for (E)xponent
  70.     call    stdout        ; send it out
  71. ;
  72. ; now the exponent
  73.     mov    dx,decexp    ; grab the exponent
  74.     cmp    dx,0        ; check sign
  75.     mov    al,'+'        ; plus sign
  76.     jge    tdecshow4    ; if non-negative
  77. ;
  78. ; if negative exponent
  79.     neg    dx        ; absolute value of exponent
  80.     mov    al,'-'        ; minus sign
  81. ;
  82. tdecshow4:
  83.     call    stdout        ; output sign of exponent
  84.     call    dec16out    ; output exponent
  85. ;
  86.     ret            ; return
  87. ;
  88. tdecshow    endp
  89. ;-------------------------tdecshow routine ends---------------------------+
  90.